var async=require('async');
var mock=require('./mock.js');

//可以让我们给一个函数预绑定多个参数并生成一个可直接调用的新函数，简化代码。

var writeFile=(data,path,cb)=>{
    setTimeout(()=>{
        console.log(data,path);
        cb(null,data,path);
    },Math.random()>0.5?1000:500);
};

/*async.parallel([
    async.apply(writeFile,'data-1','file-1'),
    async.apply(writeFile,'data-2','file-2'),
    async.apply(writeFile,'data-3','file-3')
],(err,ret)=>{
    console.log('ret:',err,ret);
});*/

async.parallel([
    async.apply(mock.getUrl,'a.com'),
    async.apply(mock.getUrl,'b.com'),
    async.apply(mock.getUrl,'c.com'),
],(err,ret)=>{
    console.log('ret:',err,ret);
});